<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>IFE JavaScript Task 01</title>
</head>
<body>

    <label for="aqi-input">请输入北京今天空气质量：<input type="text" id="aqi-input"></label>
    <button id="button">确认填写</button>

    <div>您输入的值是：<span id="aqi-display">尚无录入</span></div>

    <script>
        (function(){

            var $ = function (id){
                return document.getElementById(id);
            }

            var bindEvent = function(ele, event_name, func){
                if(window.attachEvent){
                    ele.attachEvent(event_name, func);
                }else{
                    event_name = event_name.replace(/^on/, "");
                    ele.addEventListener(event_name, func);
                }
            }

            var aqi_input = $("aqi-input"),
                aqi_display = $("aqi-display"),
                button = $("button");

            bindEvent(button, "onclick", function(){
                var aqi_text = aqi_input.value;
                aqi_display.innerHTML = aqi_text;
            })



        })();
    </script>
</body>
</html>